#include "compile.h"
#include "code.h"

void CallVCScript(unsigned char idcode)
{ char *ptr, *optr, varctr=0;

         EmitC (EXEC);
         EmitC (idcode);
         Expect ("(");
         ptr = cpos;
         EmitC (varctr);
         EmitOperand ();
         while (!NextIs(")"))
         {
                Expect (",");
                EmitOperand();
                varctr++;
         }
         optr = cpos;
         cpos = ptr;
         EmitC (varctr);
         cpos = optr;
         Expect(")");
         Expect(";");
}

void TextMenu(unsigned char idcode)
{ char *ptr, *optr, varctr=1;

         EmitC (EXEC);
         EmitC (idcode);
         Expect ("(");
         EmitOperand ();  // x
         Expect (",");
         EmitOperand();   // y
         Expect (",");
         EmitOperand();   // flagidx
         Expect (",");
         EmitOperand();   // ptr
         Expect (",");

         ptr = cpos;
         EmitC (varctr);
         GetString ();
         EmitString(token);
         while (!NextIs(")"))
         {
                Expect (",");
                GetString ();
                EmitString(token);
                varctr++;
         }
         optr = cpos;
         cpos = ptr;
         EmitC (varctr);
         cpos = optr;
         Expect(")");
         Expect(";");
}

void VCTextBox(unsigned char idcode)
{ char *ptr, *optr, varctr=1;

         EmitC (EXEC);
         EmitC (idcode);
         Expect ("(");
         EmitOperand ();  // x
         Expect (",");
         EmitOperand();   // y
         Expect (",");
         EmitOperand();   // ptr
         Expect (",");

         ptr = cpos;
         EmitC (varctr);
         GetString ();
         EmitString(token);
         while (!NextIs(")"))
         {
                Expect (",");
                GetString ();
                EmitString(token);
                varctr++;
         }
         optr = cpos;
         cpos = ptr;
         EmitC (varctr);
         cpos = optr;
         Expect(")");
         Expect(";");
}

